//
// @Auther: by wujehy 
// @Email:wujehy@qq.com
// @Data:2019/10/08
// @Time:9:48 上午
//
//

#include "mosquitto_broker.h"
#include "mosquitto.h"
#include "mosquitto_internal.h"
const char *mosquitto_client_address(const struct mosquitto *client)
{
    return client->address;
}


bool mosquitto_client_clean_session(const struct mosquitto *client)
{
    return client->clean_start;
}


const char *mosquitto_client_id(const struct mosquitto *client)
{
    return client->id;
}


int mosquitto_client_keepalive(const struct mosquitto *client)
{
    return client->keepalive;
}


void *mosquitto_client_certificate(const struct mosquitto *client)
{
#ifdef WITH_TLS
    if(client->ssl){
		return SSL_get_peer_certificate(client->ssl);
	}else{
		return NULL;
	}
#else
    return NULL;
#endif
}


int mosquitto_client_protocol(const struct mosquitto *client)
{
#ifdef WITH_WEBSOCKETS
    if(client->wsi){
		return mp_websockets;
	}else
#endif
    {
        return mp_mqtt;
    }
}


//int mosquitto_client_sub_count(const struct mosquitto *client)
//{
//    return client->sub_count;
//}


const char *mosquitto_client_username(const struct mosquitto *context)
{
#ifdef WITH_BRIDGE
    if(context->bridge){
		return context->bridge->local_username;
	}else
#endif
    {
        return context->username;
    }
}

